import   javax.mail.Message; 
import   javax.mail.Transport; 
import   javax.mail.Session; 

import   java.util.Properties; 

import   javax.mail.internet.MimeMessage; 
import   javax.mail.internet.InternetAddress; 
import   javax.mail.MessagingException; 

/** 
  *   @author   Administrator 
  *   找回密码 
  *   / 
public   class   Send   {	
public   static   void   main(String[]   args)throws   Exception{ 
new   Send().sendMail(); 
} 

private   String   host= "smtp.126.com ";//主机； 
private   String   user= "xiaye09080201 ";//用户名； 
private   String   password= "11111111 ";//密码； 
private   String   from= "xiaye09080201@126.com ";//发件人； 
private   String   to= " ";//收件人； 
private   String   subjetc= "六八四八竟价排名系统给您的密码提示 ";//标题； 
private   String   content= " ";//内容； 

//设置内容 
public   void   setContent(String   content)   { 
this.content   =   content; 
} 
//设置收件人 
public   void   setTo(String   to)   { 
this.to   =   to; 
} 

/** 
  *   发送email 
  *   @throws   MessagingException 
  *   @throws   Exception 
  */ 
public   void   sendMail()   throws   MessagingException,Exception{ 

Properties   props   =   new   Properties(); 
        props.put( "mail.smtp.host ",   host);//指定SMTP服务器 
        props.put( "mail.smtp.auth ",   "true ");//指定是否需要SMTP验证 
    
        Session   mailSession   =   Session.getDefaultInstance(props); 
      
        Message   message=new   MimeMessage(mailSession); 
        message.setFrom(new   InternetAddress(from));//发件人 
        message.addRecipient(Message.RecipientType.TO,new   InternetAddress(to));//收件人 
      
        message.setSubject(subjetc);//邮件主题 
        message.setText(content);//邮件内容 
        message.saveChanges(); 
      
        Transport   transport   =   mailSession.getTransport( "smtp "); 
        transport.connect(host,   user,   password); 
        transport.sendMessage(message,   message.getAllRecipients()); 
        transport.close(); 
        
        } 

}